﻿using System.Net;

namespace DNNToolkit.SQLServerReporting.Components
{
    public class CustomReportCredentials : Microsoft.Reporting.WebForms.IReportServerCredentials
    {
        private string mUserName;
        private string mPassWord;
        private string mDomainName;

        public CustomReportCredentials(string UserName, string PassWord, string DomainName)
        {
            mUserName = UserName;
            mPassWord = PassWord;
            mDomainName = DomainName;
        }        

        #region IReportServerCredentials Members

        bool Microsoft.Reporting.WebForms.IReportServerCredentials.GetFormsCredentials(out Cookie authCookie, out string userName, out string password, out string authority)
        {
            // not use FormsCredentials unless you have implements a custom autentication.
            authCookie = null;
            userName = password = authority = null;
            return false;
        }

        System.Security.Principal.WindowsIdentity Microsoft.Reporting.WebForms.IReportServerCredentials.ImpersonationUser
        {
            get
            {
                return null;  // not use ImpersonationUser
            }
        }

        ICredentials Microsoft.Reporting.WebForms.IReportServerCredentials.NetworkCredentials
        {
            get
            {
                // use NetworkCredentials
                return new NetworkCredential(mUserName, mPassWord, mDomainName);
            }
        }

        #endregion
    }
}
